<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
	<meta content="personal wiki system 个人wiki系统" name="keyword"/>
	<link rel="stylesheet" type="text/css" href="welcome.css"/>
	
	<script src="prototype-1.6.0.3.js" type="text/javascript"></script>
	<title>个人wiki系统</title>
	<script>
		
		var currentItemTitle = "";
		
	 function UrlEncode(str){      //主函数
	   var ret="";
	   var strSpecial="!\"#$%&'()*+,/:;<=>?[]^`{|}~%";
	   for(var i=0;i<str.length;i++){
	   var chr = str.charAt(i);
	     var c=str2asc(chr);
	     if(parseInt("0x"+c) > 0x7f){
	       ret+="%"+c.slice(0,2)+"%"+c.slice(-2);
	     }else{
	       if(chr==" ")
	         ret+="+";
	       else if(strSpecial.indexOf(chr)!=-1)
	         ret+="%"+c.toString(16);
	       else
	         ret+=chr;
	     }
	   }
	   return ret;
	}


	function str2asc(ch){  
		var Strob=new String(ch);
		var sstr="";
		for(var i=0;i<Strob.length;i++){
		   sstr+=new String(Strob.substr(i,1)).charCodeAt(0).toString(16);
		}
		return sstr;
		
	}
		
		onload = function()
		{
			$('search').focus();
			var now= new Date();
			var year=1900 + now.getYear();
			var month=now.getMonth()+1;
			var day=now.getDate();

			document.getElementById( 'informationBox' ).innerHTML = '今天是' + year+"年"+month+"月"+day+"日";
			
			//get welcome page
			new Ajax.Updater(
					"article",
					"/personelwiki",
					{method: "get", parameters: "methodID=1&method=goTo&title=welcome"}
				);
			currentItemTitle = "welcome";
		};
		
		
		
		function search1()
		{
			try
			{
				alert( 'not avaliable now!' );
				//alert($('search1'));
				/*$( 'search' ).focus();
				new Ajax.Updater(
					"article",
					"/personelwiki",
					{method: "get", parameters: "methodID=1&method=goTo&title=baidu"}
				);
				*/
				
				
			} 
			catch ( e )
			{
				alert(e);
			}
		}
		
		function search2()
		{
			try {
				//alert( $F('search'));
				//alert('search2 press!');
				var query = $F('search');
				//var params = "methodID=2&method=searchItem&query=" + query;
				new Ajax.Updater("article", "/personelwiki", {
					method: "get",
					parameters: {"methodID":"2", "method":"searchItem", "query":query}
				});
			} catch ( e ) {
				alert( e );
			}
			
			currentItemTitle = query;
			
		}
		
		
		function goTo( item )
		{
			currentItemTitle = item;
			//go to the specified item
			new Ajax.Updater(
					"article",
					"/personelwiki",
					{method: "get", 
					parameters: {"methodID":"1", "method":"goTo", "title":item}
					}
				);
				
			$('search').focus();
			
		}
		
		/**
		创建新的item
		*/
		function createNew( item )
		{
			try {
				currentItemTitle = item;
				var title = "<h1>" + item + "</h1>";
				$("article").innerHTML = title + "<textarea id=\"editInput\"></textarea>";
			} catch ( e ) {
				alert( e );
			}
		}
		
		function edit()
		{
			try {
				var title = "<h1>" + currentItemTitle + "</h1>";
				$("article").innerHTML = title + "<textarea id=\"editInput\"></textarea>";
			} catch ( e ) {
				alert( e );
			}
			
			new Ajax.Updater(
					"editInput",
					"/personelwiki",
					{method: "get", 
					parameters: {"methodID":"4", "method": "edit","title":currentItemTitle}
					}
				);
			
		}
		
		function history()
		{
			
		}
		
		function category()
		{
			
		}
		
		function save()
		{
			try {
				//alert($F('editInput'));
				var content = $F('editInput');
				var params = "methodID=3&method=save&content=" +
				content +
				"&title=" +
				currentItemTitle +
				"&author=chencai";
				//alert(params);
				new Ajax.Updater("article", "/personelwiki", {
					method: "post",
					parameters: {"methodID":"3", 
								"method":"save", 
								"content":content,
								"title":currentItemTitle,
								"author":"chencai"}
				});
			} catch ( e ) {
				alert( e );
			}
			
			$('search').focus();
			
		}
		
		function cancel()
		{
			goTo( currentItemTitle );
		}
		
		function test()
		{
			//alert("press !");
			
			try {
				
				new Ajax.Updater(
					"article",
					"/wiki/images/test.html",
					{method: "get"}
				);
				
				
				$( 'btnHistory' ).style.width= '0px';
				$( 'btnHistory' ).style.visibility = 'hidden';
				
			}
			catch ( e )
			{
				alert(e);
			}
		}
	</script>
</head>
<body>
	<div class="wrap">
		<div class="head">
			<div class="logo"><a href="http://chen-cai.appspot.com"><img src="images/logo.jpg" width="107" height="49" alt="Chencai's Wiki Page" title="Wiki" /></a></div>
 		    <div class="navLink"><a href="http://chen-cai.appspot.com">主页</a> | <a href="#">系统介绍</a> | <a href="#"><span class="fEn">Introduction</span></a></div>
 		</div>
		<div class="main">
			<div class="sideBar">
				<div class="searchBox">
					<input id="search" />
				</div>
				<div>
					<a id="search1" href="#r" onclick="search1();" class="button2">搜类别</a>
					<a id="search2" href="#" onclick="search2();" class="button2">搜词条</a>
				</div>
				<div id="informationBox" class="informationBox">
					
				</div>
			</div>
			<div class="content">
				<div class="tbuttons">
					<a id="edit1" href="#" onclick="edit();" class="button1">编辑</a> 
	  				<a id="history1" href="#" onclick="history();" class="button1" >历史</a>
	 	 			<a id="category1" href="#" onclick="category();" class="button1">类别</a>
					<a id="save1" href="#" onclick="save();" class="button1">保存</a>
					<a id="cancel1" href="#" onclick="cancel();" class="button1">取消</a>
				</div>
				
				<div class="article" id="article">
					<!--<h2 class="title">欢迎访问个人wiki系统<span class="fEn">Personal Wiki System</span> <em>2010-01-07</em></h2>

					<p> 　　2010年1月6日，全球最大的中文搜索引擎百度宣布，正式组建独立网络视频公司，全面进军正版高清网络视频领域。百度官方证实，原12580总裁兼COO龚宇已受邀出任新公司CEO。龚宇拥有丰富的互联网公司运营和管理经验，曾成功创办焦点房地产网，并担任搜狐COO等重要职务。</p>
       				<p>　　据透露，新公司运营模式不同于目前市场上主要的视频分享模式，百度新成立的视频公司旨在通过与上游版权商密切合作，免费向广大互联网用户提供全正版电影、电视剧、体育、动漫等一系列丰富的高清视频内容。</p>
					-->
					<p>正在加载欢迎画面，请等待......</p>
				</div>
				
				<div class="bbuttons">
					<a id="edit2" href="#" onclick="edit();" class="button1">编辑</a> 
	  				<a id="history2" href="#" onclick="history();" class="button1" >历史</a>
	 	 			<a id="category2" href="#" onclick="category();" class="button1">类别</a>
					<a id="save2" href="#" onclick="save();" class="button1">保存</a>
					<a id="cancel2" href="#" onclick="cancel();" class="button1">取消</a>
				</div>
			</div>
		</div>
	</div>
	
	<div class="footer">
		<p ><span class="fEn">Copyright &copy; 2010 chencai.com.All Rights Reserved</span></p>

	</div>
</body>

	